Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Procstat: don't cache PIDs" #2479

Merged
merged 1 commit into from
Mar 6, 2017
Merged

Conversation

sparrc
Copy link
Contributor

@sparrc sparrc commented Mar 1, 2017

Reverts #2206

@sparrc
Copy link
Contributor Author

sparrc commented Mar 1, 2017

cc @jarondl Unfortunately I need to revert your PR.

I have just realized that this results in the cpu_usage of the process not working, since this relies on caching the previous values of CPU times.

Please feel free to resubmit your PR if you can find a solution around this.

@sparrc
Copy link
Contributor Author

sparrc commented Mar 1, 2017

cc @danielnelson

@jarondl
Copy link
Contributor

jarondl commented Mar 1, 2017

Yikes. So gopsutil only gives correct cpu times if you keep using the same object?

@sparrc
Copy link
Contributor Author

sparrc commented Mar 1, 2017

That's correct, and it's not possible for gopsutil to workaround this. Calculating CPU usage inherently requires two "cpu time" readings, which is why the first collection of CPU metrics never has any usage fields defined.

@jarondl
Copy link
Contributor

jarondl commented Mar 1, 2017

Well the correct (but backwards incompatible) way to architecture this is to save cumulative cpu time itself.
Then the dashboard / alerting tool can calculate the cpu usage (e.g. grafana's non_negative_derivative)

The other benefit of this scheme is that even if you miss a read you don't miss a cpu usage spike.

@danielnelson
Copy link
Contributor

Could be useful to have a cpu_time metric, but I think we will also want a simple to graph stat like the cpu_usage. We should be able to recreate processes only for pids that change, I doubt the pid would be reused so quickly as to not be detected.

@sparrc
Copy link
Contributor Author

sparrc commented Mar 1, 2017

@jarondl CPU time -> % usage isn't quite that simple and is platform-specific, I think it would be a bit abnormal for a data collector that doesn't do the usage calculation itself.

We do already provide the raw time metrics if you want them, but we fielddrop them by default.

@sparrc sparrc merged commit 7a8e821 into master Mar 6, 2017
@danielnelson danielnelson deleted the revert-2206-procstat_nocache branch March 17, 2017 00:12
ssorathia pushed a commit to ssorathia/telegraf that referenced this pull request Mar 25, 2017
calerogers pushed a commit to calerogers/telegraf that referenced this pull request Apr 5, 2017
vlamug pushed a commit to vlamug/telegraf that referenced this pull request May 30, 2017
maxunt pushed a commit that referenced this pull request Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants